
/**
 * 流动显示 结构：外层一个容器Div 显示用 里面一个容器Div 流动对象
 * 
 */

window.onload = function() {
	move('screen');
}

function move(screen) {
	var _time = 100;
	// 定时器
	var _timerMoveNodes;
	var _screen = document.getElementById(screen);
	// 取得流动对象
	var _screenWidth = _screen.clientWidth;
	var _screenX = _screen.clientLeft;
	var _screenX2 = _screenWidth + _screenX;
	var _items = _screen.children;
	var _nodeWidth;
	if (_items.length > 0) {
		_nodeWidth = _items[0].clientWidth;
	}
	// 移动任务
	var moveNodes = function() {
		for (i = 0; i < _items.length; i++) {
			var _item = _items[i];
			// console.dir(_item.style);
			var _left = _item.style.left;
			_left = _left == '' ? _left = 0 : _left = parseInt(_left);

			_left -= 4;

			if ((_left + _nodeWidth) < _screenX) {
				_item.style.left = _screenX2 + 'px';
			} else {
				_item.style.left = _left + 'px';
			}
			_item.style.position = 'absolute';
		}
	}

	_timerMoveNodes = setInterval(moveNodes, _time);
	
	_screen.onmouseout = function(){
		_timerMoveNodes = setInterval(moveNodes, _time);
	}
	_screen.onmouseover = function(){
		clearInterval(_timerMoveNodes);
	}
}
